package com.liuqianfei.markdown;

/**
 * 默认标签装饰实现。
 *
 * <p>
 * 例如&lt;p&gt;标签实现。
 * </p>
 *
 * <pre>
 * <code>public class MyDecorator extends DefaultDecorator
 * {
 *     &#64;Override
 *     public void openParagraph(StringBuilder out)
 *     {
 *         out.append("&lt;p class=\"myclass\"&gt;");
 *     }
 * }
 * </code>
 * </pre>
 *
 */
public class DefaultDecorator implements Decorator
{
    public DefaultDecorator()
    {
    }

    @Override
    public void openParagraph(final StringBuilder out)
    {
        out.append("<p>");
    }

    @Override
    public void closeParagraph(final StringBuilder out)
    {
        out.append("</p>\n");
    }

    @Override
    public void openBlockquote(final StringBuilder out)
    {
        out.append("<blockquote>");
    }

    @Override
    public void closeBlockquote(final StringBuilder out)
    {
        out.append("</blockquote>\n");
    }

    @Override
    public void openCodeBlock(final StringBuilder out)
    {
        out.append("<pre><code>");
    }

    @Override
    public void closeCodeBlock(final StringBuilder out)
    {
        out.append("</code></pre>\n");
    }

    @Override
    public void openCodeSpan(final StringBuilder out)
    {
        out.append("<code>");
    }

    @Override
    public void closeCodeSpan(final StringBuilder out)
    {
        out.append("</code>");
    }

    /**
     * @see com.liuqianfei.markdown.github.rjeschke.txtmark.Decorator#openHeadline(StringBuilder,
     *      int)
     */
    @Override
    public void openHeadline(final StringBuilder out, final int level)
    {
        out.append("<h");
        out.append(level);
    }

    @Override
    public void closeHeadline(final StringBuilder out, final int level)
    {
        out.append("</h");
        out.append(level);
        out.append(">\n");
    }

    @Override
    public void openStrong(final StringBuilder out)
    {
        out.append("<strong>");
    }

    @Override
    public void closeStrong(final StringBuilder out)
    {
        out.append("</strong>");
    }

    @Override
    public void openEmphasis(final StringBuilder out)
    {
        out.append("<em>");
    }

    @Override
    public void closeEmphasis(final StringBuilder out)
    {
        out.append("</em>");
    }

    @Override
    public void openSuper(final StringBuilder out)
    {
        out.append("<sup>");
    }

    @Override
    public void closeSuper(final StringBuilder out)
    {
        out.append("</sup>");
    }

    @Override
    public void openOrderedList(final StringBuilder out)
    {
        out.append("<ol>\n");
    }

    @Override
    public void closeOrderedList(final StringBuilder out)
    {
        out.append("</ol>\n");
    }

    @Override
    public void openUnorderedList(final StringBuilder out)
    {
        out.append("<ul>\n");
    }

    @Override
    public void closeUnorderedList(final StringBuilder out)
    {
        out.append("</ul>\n");
    }

    @Override
    public void openListItem(final StringBuilder out)
    {
        out.append("<li");
    }

    @Override
    public void closeListItem(final StringBuilder out)
    {
        out.append("</li>\n");
    }

    @Override
    public void horizontalRuler(final StringBuilder out)
    {
        out.append("<hr />\n");
    }

    @Override
    public void openLink(final StringBuilder out)
    {
        out.append("<a");
    }

    @Override
    public void closeLink(final StringBuilder out)
    {
        out.append("</a>");
    }

    @Override
    public void openImage(final StringBuilder out)
    {
        out.append("<img");
    }

    @Override
    public void closeImage(final StringBuilder out)
    {
        out.append(" />");
    }

    @Override
    public void openStrike(StringBuilder out)
    {
        out.append("<s>");
    }

    @Override
    public void closeStrike(StringBuilder out)
    {
        out.append("</s>");
    }
}
